package com.atguigu.scala.chapter6

/**
 * @author lizikuan
 * @date 2021/5/21 21:02
 */
object $05_Trait {

  trait Logger{

    val name = "logger"

    val age:Int

    def add(x:Int,y:Int)=x+y

    def sum(x:Int,y:Int):Int
  }

  trait Logger1{
    val name = "logger1"
  }
  trait Logger2{
    val name = "logger2"
  }
  trait Logger3{
    val name = "logger3"
  }
  class person

  class Sun extends Logger with Logger1 with Logger2 with Logger3 {
    override val name: String = "asdasda"
    override val age: Int = 100

    override def sum(x: Int, y: Int): Int = x*y
  }

  def main(args: Array[String]): Unit = {
    val sun = new Sun
    val person = new person with Logger3
    println(person.name)
    println(sun.add(1, 2))
    println(sun.sum(3, 2))
  }
}
